package com.itlong.cloud.controller.project;

import com.itlong.cloud.POJO.DTO.operate.OperateAppTypeDTO;
import com.itlong.cloud.POJO.DTO.operate.OperateAppTypeGetPageDTO;
import com.itlong.cloud.POJO.VO.MessageVO;
import com.itlong.cloud.abstracts.BaseController;
import com.itlong.cloud.annotation.UnAuthAccessRequired;
import com.itlong.cloud.annotation.UnParamEncrypt;
import com.itlong.cloud.enumerate.ecode.BaseErrorCodeEnum;
import com.itlong.cloud.project.operate.IOperateAppTypeServiceClient;
import com.itlong.cloud.thrown.DataAccessException;
import org.apache.commons.lang.StringUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;

/**
 * <desc>
 *     应用类型控制器
 * </desc>
 *
 * @createDate 2021-08-04
 */
@RestController
@RequestMapping("/appType")
public class OperateAppTypeController  extends BaseController {

    @Resource
    IOperateAppTypeServiceClient iOperateAppTypeServiceClient;

    /**
    * <desc>
    *      查询、获取分页列表
    * </desc>
    * @param appTypeGetPageDto
    * @return: java.lang.Object
    * @author LiuYu
    * @date: 2021-08-16
     **/
    @UnAuthAccessRequired
    @UnParamEncrypt
    @RequestMapping(path = "getAppTypeList" ,method = RequestMethod.POST)
    public Object getAppTypeList( OperateAppTypeGetPageDTO appTypeGetPageDto){
        MessageVO messageVO;
        try {
            messageVO = new MessageVO(BaseErrorCodeEnum.SUCCESS.getErrorCode(),iOperateAppTypeServiceClient.getAppTypeList(appTypeGetPageDto));
        }catch (Exception e){
            throw new DataAccessException("【运营_系统_应用类型getAppTypeList】获取应用类型列表失败",e);
        }
        return messageVO;

    }
    /**
     * <desc>
     *      添加接口类型
     * </desc>
     *
     * @param operateAppTypeDTO
     * @return java.lang.Object
     * @author liuyu
     * @createDate 2021-08-13
     */
    @UnAuthAccessRequired
    @UnParamEncrypt
    @RequestMapping(path = "save" ,method = RequestMethod.POST)
    public Object save( OperateAppTypeDTO operateAppTypeDTO) throws Exception{
        MessageVO messageVO;
        try {
            messageVO = new MessageVO(BaseErrorCodeEnum.SUCCESS.getErrorCode(),iOperateAppTypeServiceClient.save(operateAppTypeDTO));
        }catch (Exception e){
            throw new DataAccessException("【运营_系统_应用类型save】添加应用类型失败",e);
        }
        return messageVO;
    }


    /**
     * <desc>
     *      修改接口类型
     * </desc>
     *
     * @param operateAppTypeDTO
     * @return java.lang.Object
     * @author liuyu
     * @createDate 2021-08-13
     */
    @UnAuthAccessRequired
    @UnParamEncrypt
    @RequestMapping(path = "update" ,method = RequestMethod.POST)
    public Object update( OperateAppTypeDTO operateAppTypeDTO) throws Exception{
        MessageVO messageVO;
        try {
            messageVO = new MessageVO(BaseErrorCodeEnum.SUCCESS.getErrorCode(),iOperateAppTypeServiceClient.update(operateAppTypeDTO));
        }catch (Exception e){
            throw new DataAccessException("【运营_系统_应用类型update】更新应用类型失败",e);
        }
        return messageVO;
    }

    /**
    * <desc>
    *      批量删除
    * </desc>
    * @param ids
    * @return: java.lang.Object
    * @author LiuYu
    * @date: 2021-08-16
     **/
    @UnAuthAccessRequired
    @UnParamEncrypt
    @RequestMapping(path = "delete" ,method = RequestMethod.POST)
    public Object delete(String ids){
        MessageVO messageVO;
        try {

            if(StringUtils.isBlank(ids) ){
                throw new DataAccessException("【运营_系统_应用类型delete】删除应用类型失败",new Exception());
            }
            messageVO = new MessageVO(BaseErrorCodeEnum.SUCCESS.getErrorCode(),iOperateAppTypeServiceClient.delete(ids));
        }catch (Exception e){
            throw new DataAccessException("【运营_系统0_应用类型delete】删除应用类型失败",e);
        }
        return messageVO;
    }

    /**
    * <desc>
    *      获取分配接口类型
    * </desc>
    * @param appTypeId
    * @return: java.lang.Object
    * @author LiuYu
    * @date: 2021-08-16
     **/
    @UnAuthAccessRequired
    @UnParamEncrypt
    @RequestMapping(path = "getAllotInterfaces" ,method = RequestMethod.POST)
    public Object getAllotInterfaces(String appTypeId){
        MessageVO messageVO;
        try {
            messageVO = new MessageVO(BaseErrorCodeEnum.SUCCESS.getErrorCode(),iOperateAppTypeServiceClient.getAllotInterfaces(appTypeId));
        }catch (Exception e){
            throw new DataAccessException("【运营_系统_应用类型getAllotInterfaces】获取接口菜单列表失败",e);
        }
        return messageVO;
    }
    /**
    * <desc>
    *      提交接口类型
    * </desc>
     * @param appTypeId
     * @param ids
    * @return: java.lang.Object
    * @author LiuYu
    * @date: 2021-08-13
     **/
    @UnAuthAccessRequired
    @UnParamEncrypt
    @RequestMapping(path = "commitAllotInterfaces" ,method = RequestMethod.POST)
    public Object commitAllotInterfaces(String appTypeId,String ids){
        MessageVO messageVO;
        try {
            messageVO = new MessageVO(BaseErrorCodeEnum.SUCCESS.getErrorCode(),iOperateAppTypeServiceClient.commitAllotInterfaces(appTypeId,ids));
        }catch (Exception e){
            throw new DataAccessException("【运营_系统_应用类型commitAllotInterfaces】分配接口类型提交失败",e);
        }
        return messageVO;
    }
}
